#include "PlannerEnemy.h"
#include "..\GameEngine.h"
#include "AbstractClasses\GameEntity.h"
#include "..\Dependencies.h"
#include "..\Scene\SceneManager.h"
#include "..\Games\MyGame.h"
#include <fstream>
#include <iostream>

PlannerEnemy::PlannerEnemy(int maxFrequency, std::string name) : Enemy(maxFrequency, name) {
	moveActions.push_back(LEFT);
	moveActions.push_back(RIGHT);
	moveActions.push_back(UP);
	moveActions.push_back(DOWN);
}

PlannerEnemy::~PlannerEnemy() {
}

void PlannerEnemy::reset(){}

int PlannerEnemy::getType() {
	return PLANNERENEMY;
}

void PlannerEnemy::draw()
{	
	SCALE scale = {0.3,0.6,0.3};
	GameEngine::Instance()->getRenderer()->drawPieceQuad("assets/spaceship3.raw\0", 1,1,1, this->getPosition(),this->getOrientation(), scale, 128,128,getColor());
}

void PlannerEnemy::actualUpdate(unsigned long long timePassed)
{
	doSomething();
}

void PlannerEnemy::sense() {
}
void PlannerEnemy::reason() {							
	SceneNode * n = SceneManager::Instance()->getRootSceneNode();
	GameEntity * ship = n->getEntity("ship");
	POINT3D goal = ship->getPosition();//{8.0f,8.0f,0.0f};
	if(plan.size() == 0 && MyGame::Instance()->getEnv()->distance(getPosition(), goal) > 0.1) { //If the plan is empty and the current goal is not been reached, make a plan!		
		array1d *distanceMap = new array2d;
		createDistanceMap(goal, distanceMap);	//<-- something does not work!!!
		//planPath(distanceMap);
		delete distanceMap;
	}	
}
float PlannerEnemy::evaluate(POINT3D) { //PlannerEnemy does not evaluate
	return 0.0;
}